#include <stdio.h>

int main(){
    int** array=NULL;
    int n=0,x,y;
    int i;

    scanf("%d",&n);
    array=new int*[n];
    for(i=0;i<n;i++)
    {
        array[i]=new int[4];
        scanf("%d %d %d %d",&array[i][0],&array[i][1],&array[i][2],&array[i][3]);
        array[i][2]+=array[i][0];
        array[i][3]+=array[i][1];
    }

    scanf("%d %d",&x,&y);
    int result=-1;
    for(i=n-1;i>=0;i--)
    {
        if(x>=array[i][0]&&x<=array[i][2]&&y>=array[i][1]&&y<=array[i][3])
        {
            result=i+1;
            break;
        }
    }

    if(array!=NULL)
    {
        for(i=0;i<n;i++)
        {
            delete array[i];
        }
        delete array;
    }

    printf("%d\n",result);
    return 0;
}